using UnityEngine;
using System.Collections;

public class PathNodeContainer : MonoBehaviour {
	
	public void LinkAdjacentNode() {
		PathNode[] pl;
		pl = gameObject.GetComponentsInChildren<PathNode>();
		
		ArrayList tempAry = new ArrayList();
		foreach (PathNode p1 in pl) {
			tempAry.Clear();
			foreach (PathNode p2 in pl) {
				if (p1 != p2) {
					float dis = Vector3.Distance(p1.trans.position, p2.trans.position);
					if (dis < (p1.radius + p2.radius) ) {
						tempAry.Add(p2);
					}
				}
			}
			
			
			int size = tempAry.Count;
			p1.realAdjacentNodes = new PathNode[size];
			for (int i = 0; i < size; i++) {
				p1.realAdjacentNodes[i] = (PathNode)tempAry[i];	
			}
		}
	}
	
	public PathNode[] getPathNodeArray() {
		return (PathNode[])GetComponentsInChildren<PathNode>();
		
	}
	
	public int getContainerSize() {
		PathNode[] pl = GetComponentsInChildren<PathNode>();
		
		return pl.Length;
	}
}
